package cn.class2.demo8

/**
  * Created by lzd on 2018/9/6.
  * scala 柯里化
  * implicit 隐式值
  */
class CurrDemo {

}

object CurrDemo {

  def curr1(a: Int, b: Int): Int = {
    return a * b
  }

  def curr2(a: Int)(b: Int): Int = {
    return a * b
  }

  def curr3(a: Int)(b: Int)(c: Int): Int = {
    return a * b * c
  }

  def main(args: Array[String]): Unit = {
    println(curr1(2, 2))
    println(curr2(2)(2))
    val f1 = (curr2(2) _)
    println(f1(2))

    println("=================================")

    val cf1 = curr3(2) _
    println(cf1)
    println(cf1(2)(3))
    val cf2 = cf1(2)
    println(cf2(3))

    /**
      * implicit val aa: Int = 100
      * 如果在执行环境中有定义隐式值的话，默认值失效
      */



    def curr4(a: Int)(implicit b: Int = 10): Int = {
      return a * b
    }

    println(curr4(2))
    println(curr4(2)(100))
  }
}
